package dw.catalog

import grails.rest.*
import dw.content.MarkupText
import dw.content.MediaFile
import dw.object.ExtensibleObject
import dw.value.Quantity

/**
 * Represents a product in the Demandware framework. 
 * Products are identified by a unique product ID, sometimes called the SKU.
 */
class Product extends ExtensibleObject {
	
	ProductActiveData 			activeData
	
	Collection 					allCategories,
								allCategoryAssignments,
								allIncomingProductLinks,
								allProductLinks,
								bundledProducts,
								bundles,
								categories,
								categoryAssignments,
								incomingProductLinks,
								onlineCategories,
								orderableRecommendations,
								productLinks,
								productSetProducts,
								productSets,
								recommendations
				
	boolean 					assignedToSiteCatalog,
								available,
								availableFlag,
								bundle,
								bundled,
								categorized,
								master,
								online,
								onlineFlag,
								optionProduct,
								product,
								productSet,
								productSetProduct,
								retailSet,
								searchable,
								searchableFlag,
								siteProduct
				
	ProductAttributeModel 		attributeModel
	
	ProductAvailabilityModel 	availabilityModel
	
	String 						brand,
								EAN,
								dwID,
								manufacturerName,
								manufacturerSKU,
								name,
								pageDescription,
								pageKeywords,
								pageTitle,
								pageURL,
								siteMapChangeFrequency,
								taxClassID,
								template
				
	Category 					classificationCategory,
								primaryCategory
							
	MediaFile 					image,
								thumbnail
							
	MarkupText 					longDescription,
								shortDescription
							
	Quantity 					minOrderQuantity,
								stepQuantity
							
	Date						onlineFrom,
								onlineTo
							
	ProductOptionModel 			optionModel
	
	ProductPriceModel 			priceModel
	
	CategoryAssignment 			primaryCategoryAssignment
	
	Number 						searchPlacement,
								searchRank,
								siteMapPriority
	
	static constraints = {
		activeData(nullable: true)
		
		allCategories(nullable: true)
		allCategoryAssignments(nullable: true)
		allIncomingProductLinks(nullable: true)
		allProductLinks(nullable: true)
		bundledProducts(nullable: true)
		bundles(nullable: true)
		categories(nullable: true)
		categoryAssignments(nullable: true)
		incomingProductLinks(nullable: true)
		onlineCategories(nullable: true)
		orderableRecommendations(nullable: true)
		productLinks(nullable: true)
		productSetProducts(nullable: true)
		productSets(nullable: true)
		recommendations(nullable: true)
		
		assignedToSiteCatalog(nullable: true)
		available(nullable: true)
		availableFlag(nullable: true)
		bundle(nullable: true)
		bundled(nullable: true)
		categorized(nullable: true)
		master(nullable: true)
		online(nullable: true)
		onlineFlag(nullable: true)
		optionProduct(nullable: true)
		product(nullable: true)
		productSet(nullable: true)
		productSetProduct(nullable: true)
		retailSet(nullable: true)
		searchable(nullable: true)
		searchableFlag(nullable: true)
		siteProduct(nullable: true)
		
		attributeModel(nullable: true)
		
		availabilityModel(nullable: true)
		
		brand(nullable: true)
		EAN(nullable: true)
		dwID(nullable: false, blank: false)
		manufacturerName(nullable: true)
		manufacturerSKU(nullable: true)
		name(nullable: true)
		pageDescription(nullable: true)
		pageKeywords(nullable: true)
		pageTitle(nullable: true)
		pageURL(nullable: true)
		siteMapChangeFrequency(nullable: true)
		taxClassID(nullable: true)
		
		template(nullable: true)
		classificationCategory(nullable: true)
		primaryCategory(nullable: true)
		
		image(nullable: true)
		thumbnail(nullable: true)
		
		longDescription(nullable: true)
		shortDescription(nullable: true)
		
		minOrderQuantity(nullable: true)
		stepQuantity(nullable: true)
		
		onlineFrom(nullable: true)
		onlineTo(nullable: true)
		
		optionModel(nullable: true)
		
		priceModel(nullable: true)
		
		primaryCategoryAssignment(nullable: true)
		
		searchPlacement(nullable: true)
		searchRank(nullable: true)
		siteMapPriority(nullable: true)
	}
	
	static belongsTo = Category
	static hasMany = [products: Product]
	
    static mapping = {
        id generator: "uuid", name: "UUID", column: "UUID", unique:"true"
    }
}
